//
//  LabelImageCollectionCell.m
//  QuXiang
//
//  Created by Duncan on 2020/6/17.
//  Copyright © 2020 NanHuaiZi. All rights reserved.
//

#import "LabelImageCollectionCell.h"

@implementation LabelImageCollectionCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self.contentView addSubview:self.imageView];
        [self.contentView addSubview:self.titleLabel];
        [self masonryLayout];
    }
    return self;
}

#pragma mark ------- Public Methods -------

- (void)homeOneSixSixMasLayout {
    self.backgroundColor = UIColor.whiteColor;
    self.cornerRadius = kFragmemtFloat(10);
    self.titleLabel.font = kAdaptedMediumFontSize(15);
    [self.imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.size.mas_equalTo(kFragmemtFloat(32));
        make.left.equalTo(self.contentView.mas_left).offset(kFragmemtFloat(14));
    }];
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.imageView.mas_right).offset(kFragmemtFloat(12.5));
        make.right.equalTo(self.contentView.mas_right).offset(-kFragmemtFloat(14));
    }];
}

// 智能-最近使用
- (void)inteRecentUseMasLayout {
    self.titleLabel.font = kAdaptedMediumFontSize(13);
    self.titleLabel.textColor = k_Color_666666;
    [self.imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(kFragmemtFloat(43), kFragmemtFloat(43)));
        make.top.equalTo(self.contentView.mas_top).offset(kFragmemtFloat(6));
    }];
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageView.mas_bottom).offset(kFragmemtFloat(9));
        make.left.right.equalTo(self.contentView);
    }];
}

// 我的-语音三方
- (void)myThreeMasLayout {
    self.titleLabel.font = kAdaptedMediumFontSize(13);
    self.titleLabel.textColor = k_Color_A3A3A3;
    [self.imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(kFragmemtFloat(20), kFragmemtFloat(20)));
        make.bottom.equalTo(self.contentView.mas_centerY).offset(-kFragmemtFloat(6));
    }];
    [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageView.mas_bottom).offset(kFragmemtFloat(12));
        make.left.right.equalTo(self.contentView);
    }];
}

#pragma mark ------- Lazy Methods -------

- (void)masonryLayout {
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(kFragmemtFloat(22), kFragmemtFloat(22)));
        make.top.equalTo(self.contentView.mas_top).offset(kFragmemtFloat(10));
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imageView.mas_bottom).offset(kFragmemtFloat(10));
        make.left.right.equalTo(self.contentView);
    }];
}

- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
        _imageView.contentMode = UIViewContentModeScaleAspectFill;
    }
    return _imageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = UIColor.blackColor;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [_titleLabel setFont:kAdaptedFontSize(15)];
    }
    return _titleLabel;
}

@end
